package com.ihighest.app.infox.activity;

import io.rong.imkit.fragment.ConversationListFragment;
import io.rong.imlib.model.Conversation;
import android.net.Uri;
import android.os.Bundle;
import android.support.v4.app.FragmentActivity;

import com.ihighest.app.common.core.Application;
import com.ihighest.app.infox.R;
import com.ihighest.app.infox.myview.ActivityTitle;

/**
 * 聊天信息列表界面
 * 
 * @author lkx Created at 2015-10-12 下午2:51:34
 * @version 1.0
 */
public class ConversationListActivity extends FragmentActivity {

	private ActivityTitle title;

	@Override
	protected void onCreate(Bundle arg0) {
		super.onCreate(arg0);
		Application.getInstance().addActivity(this);
		setContentView(R.layout.infox_activity_conversionlist);
		title = (ActivityTitle) findViewById(R.id.mActivityTitle);
		title.setTitle("我的会话");
		title.setViewVersible(title.titleBack);
		title.setViewGone(title.titleMsg, title.titleRefresh, title.rightLayout);
		enterFragment();
	}

	/**
	 * 加载 会话列表 ConversationListFragment
	 */
	private void enterFragment() {

		ConversationListFragment fragment = (ConversationListFragment) getSupportFragmentManager().findFragmentById(R.id.conversationlist);

		Uri uri = Uri.parse("rong://" + getApplicationInfo().packageName).buildUpon().appendPath("conversationlist")
				.appendQueryParameter(Conversation.ConversationType.PRIVATE.getName(), "false") // 设置私聊会话非聚合显示
				.appendQueryParameter(Conversation.ConversationType.GROUP.getName(), "true")// 设置群组会话聚合显示
				.appendQueryParameter(Conversation.ConversationType.DISCUSSION.getName(), "false")// 设置讨论组会话非聚合显示
				.appendQueryParameter(Conversation.ConversationType.SYSTEM.getName(), "false")// 设置系统会话非聚合显示
				.build();

		fragment.setUri(uri);
	}
}
